<!--业务员结算明细-->
<template>
  <div>
    <f-search-form ref='search' :more='true' @searchHandler='searchHandler' style='margin-bottom: 10px' @exportHandler='exportHandler' :show-export-btn='true' :exportUrl='api.bhid.exportTemplate'>
      <f-search-form-item label='单号' name='orderNo' />
      <f-search-form-item label='发货日期' type='range' name='beginDate' />
    </f-search-form>
    <f-table ref='table'
             rowKey='invoiceDetailsId'
             :showSetting='false'
             :tableColumns='columns'
             :scroll='{x:true}'
             :showMultipleBtn='false'
             :showPagination='false'
             :showTotal='true'
             :multiple='false'
             handler='hySaleManSettleDetailsListHandler'
             :operator='operator'
             :autoLoad='false'
             @onSuccess='onSuccess'
             :params='queryParam'
             :api='api.bhid.list'>
       <span slot='drugType' slot-scope='text, record, index'>
           <a-tag color='#2db7f5' v-if='text=="ZY"'>自营</a-tag>
           <a-tag color='#FF0000' v-if='text=="ZS"'>招商</a-tag>
       </span>
      <span slot='sendType' slot-scope='text, record, index'>
           <a-tag color='#2db7f5' v-if='text==1'>现款</a-tag>
           <a-tag color='#FF0000' v-if='text==2'>预收款</a-tag>
           <a-tag color='#87d068' v-if='text==3'>资保金</a-tag>
           <a-tag color='purple' v-if='text==4'>全额资信</a-tag>
       </span>
      <span slot='action' slot-scope='text, record'>
         <template v-if='record.rowIndex!="合计"'>
            <a href='javascript:;' @click='$refs.orderDetailsDrawer.showDrawer(record)'>详情</a>
          </template>
        </span>
    </f-table>
    <a-divider orientation='left'>收款账户明细
    </a-divider>
    <f-table ref='settleTable' rowKey='paymentDetailsId' :operator='operator2' :showSetting='false' :tableColumns='pdColumns' :scroll='{x:true}' handler='hyPaymentDetailsPageListHandler' :showPagination='false' :showMultipleBtn='false' :multiple='false' :params='queryParam2' :showTotal='true' :autoLoad='false' :api='api.paymentDetails' style='margin-bottom: 10px'>
      <span slot='action' slot-scope='text, record' v-if='record.rowIndex!="合计"'>
          <template>
            <a @click='$refs.settleTable.del(record)'>删除</a>
          </template>
        </span>
    </f-table>
    <hy-order-details-drawer ref='orderDetailsDrawer'></hy-order-details-drawer>
    <take-bank-add-modal ref='paymentDetailsAddModal' @success='onSuccess'></take-bank-add-modal>
  </div>
</template>
<script>
import api from "../../../../js/api"
import HyOrderDetailsDrawer from "@/views/module/haiying/order/details/hyorder_details_drawer"
import TakeBankAddModal from "@/views/module/haiying/order/settle/pay/take_bank_add_modal"


export default {
  name: "SaleManSettleDetails",
  components: { TakeBankAddModal, HyOrderDetailsDrawer },
  props: {
    columns: {
      type: Array,
      default: []
    },
    isMonitor: {
      type: Object,
      default: false
    },
    invoiceData: {
      type: Object,
      default: null
    }
  },
  data() {
    let me = this
    //操作按钮
    let operator = []
    let operator2 = []
    if (this.isMonitor==false) {
      operator2.push({
        name: "添加收款账户",
        that: this,
        handler: (table, that) => {
          this.$refs.paymentDetailsAddModal.open({
            paymentId: this.queryParam2.paymentId,
            settleApplyId: this.queryParam.settleApplyId,
            invoicePaymentId: this.queryParam.invoicePaymentId,
            saleManId: this.queryParam.saleManId
          }, false)
        }
      })
    }

    return {
      api: Object.assign(api, this.api),
      multiple: false,
      deptId: "",
      visible: false,
      maxAmount: 0,
      //列表初始化查询参数
      queryParam: {
        fileName: "结算明细",
        saleManId: null
      },
      queryParam2: {
        fileName: "付款账户明细"
      },
      returnCustomBond: 0,
      selectIds: "",
      params1: {
        deptId: ""
      },
      dataSource: [],
      pdColumns: [
        {
          title: "序号",
          width: "60px",
          align: "center",
          customRender: function(text, record, index) {
            return (record.rowIndex !== "合计") ? (parseInt(index) + 1) : record.rowIndex
          }
        },
        {
          title: "开票单位",
          align: "center",
          width: "100px",
          dataIndex: "invoiceUnitName"
        },
        {
          title: "收款人",
          align: "center",
          width: "130px",
          dataIndex: "payeeName"
        },
        {
          title: "开户行",
          align: "center",
          width: "120px",
          ellipsis: true,
          dataIndex: "bankName"
        },
        {
          title: "收款账户",
          align: "left",
          width: "80px",
          dataIndex: "bankNo"
        },
        {
          title: "付款金额",
          align: "left",
          needTotal: true,
          width: "80px",
          type: 10,
          dataIndex: "settleAmount"
        }, {
          title: "付款日期",
          align: "center",
          width: "90px",
          dataIndex: "payDate"
        }, {
          title: "备注",
          align: "center",
          width: "120px",
          ellipsis: true,
          dataIndex: "remark"
        }, {
          title: "操作",
          align: "center",
          width: "80px",
          hidden:this.isMonitor,
          dataIndex: "action",
          scopedSlots: { customRender: "action" }
        }
      ],
      operator: operator,
      operator2: operator2
    }
  },
  computed: {},
  methods: {
    setData(data) {
      if (data && data.paymentId) {
        this.queryParam.payId = data.paymentId
        this.queryParam.settleApplyId = data.settleApplyId
        this.queryParam.invoicePaymentId = data.parentId
        this.queryParam2.paymentId = data.paymentId
        this.queryParam.saleManId = data.saleManId
        this.queryParam.processInstanceId = data.processInstanceId
        this.$refs["table"].refresh(false)
      }
    },
    onSuccess() {
      this.$refs["settleTable"].refresh(false)
    },
    /**
     * 查询事件
     * @param searchParams
     */
    searchTable(searchParams) {
      this.queryParam = Object.assign(this.queryParam, searchParams)
      this.$refs.table.refresh(true, searchParams)
    }
  },
  created() {
  }
}
</script>